<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>导入课表信息</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
   <script src="plug-in/jquery-plugs/form/jquery.form.js"></script>


   <script type="text/javascript" src="plug-in/Validform/js/datatype_zh-cn.js"></script>
   <link rel="stylesheet" href="plug-in/Validform/css/style.css" type="text/css">
   <link rel="stylesheet" href="plug-in/Validform/css/tablefrom.css" type="text/css">
   
   <!-- 上传文件  -->
    <link rel="stylesheet" type="text/css" href="plug-in/webUploader/css/webuploader.css" />
    <link rel="stylesheet" type="text/css" href="plug-in/webUploader/style.css" />
    <link rel="stylesheet" type="text/css" href="plug-in/webUploader/style-file-upload.css" />
    <script type="text/javascript" src="plug-in/webUploader/dist/webuploader.js?v=2"></script>
    <script type="text/javascript" src="webpage/com/mengtian_tech/smart_lab/teach/courseSchedule/course-upload.js"></script>
   
  	<style>
  		.pageTitle{
  			background-color: rgb(238,238,238);
  			height:40px;
  			line-height: 40px;
  			margin:10px;
  			border-radius: 6px;
    		padding-left: 20px;
    		font-size: 14px;
  		}
  		
  		#filePicker2{
  			display:none;
  		}
  		.flowText{
  			font-family: 'Arial Normal', Arial; font-weight: bold; color: rgb(255, 255, 255); opacity: 1;
  			text-align: right;
  		}
  		.flow{
  			background-image: url(images/courseSchedule/flow_unselect.png);
  			background-repeat: no-repeat;
  			width:130px;
  			height:30px;
  			line-height: 30px;
  			text-align: center;
  			margin-left:10px;
  			float:left;
  			margin-bottom: 10px;
  		}
  		.flow.selected{
  			background-image: url(images/courseSchedule/flow_selected.png);
  			background-repeat: no-repeat;
  			width:130px;
  			height:30px;
  			line-height: 30px;
  			text-align: center;
  		}
  		
  		}
		 
		
		.formtable {
		    margin-left: 10px;
		    width: 90%;
    	}
    	
    	.uploader .filelist li {
	    width: 110px;
	    height: 38px;
	    background: url(./bg.png) no-repeat;
	    text-align: center;
	    margin: 0 8px 20px 0;
	    position: relative;
	    display: inline;
	    float: left;
	    overflow: hidden;
	    font-size: 12px;
	}
    	
    .uploader .placeholder {
	   
	    padding-top: 0px !important;
	    background-image: none;
	}
  	</style>
 </head>
 <body>
 
 <div class="pageTitle">导入课表</div>
 <div  class="flow selected" data-label="flow1"  > 
     <span class="flowText">上传课表</span>  
  </div>
   <div  class="flow" data-label="flow1"> 
     <span class="flowText">子项对应</span>  
  </div>
   <div  class="flow" data-label="flow1"  > 
     <span class="flowText">导入完成</span>  
  </div> 
 
		<table style="" cellpadding="0" cellspacing="1" class="formtable">
			<tbody>
				<tr>
					<td align="right">
						<label class="Validform_label">
							选择学期:
						</label>
					</td>
					<td class="value">
					     	<t:CommonSelect url="semesterInfoController.do?select" value="${currentTermId}"
					  name="semesterId" textField="semesterName" idField="id"></t:CommonSelect>
					</td>
				</tr> 
			
			  
			  <tr>
					<td align="right">
						<label class="Validform_label">
							上传课表:
						</label>
					</td> 
					<td class="value">  
		         		
		         		 <div id="flash-wrapper" class="upload-wrapper small" style="width:300px;float:left;">
					        <div id="flash-container" class="container"> 
					            <div id="flash-uploader" class="uploader">
					                <div class="queueList">
					                    <div id="flash-dndArea" class="placeholder">
					                        <div id="flash-filePicker" class="filePicker"></div>
					                         
					                    </div>
					                </div>
					                <div class="statusBar" style="display:none;">
					                    <div class="progress">
					                        <span class="text">0%</span>
					                        <span class="percentage"></span>
					                    </div><div class="info"></div>
					                    <div class="btns">
					                        <div id="filePicker2"></div><div class="uploadBtn">开始上传</div>
					                    </div>
					                </div>
					            </div>
					        </div>
   						</div>
   						
   						<div style="float:left;padding-top:20px;padding-left:50px;">
   							<a class="myBtn" href="teachCourseScheduleController.do?exportXls">下载模板</a>
   						</div>
		           </td> 
			  </tr> 
			</tbody>
		</table> 
	 
		<table class="commonTable" id="courseTable">
			<thead>
				<tr>
					<th>课程编号</th><th>课程名称</th><th>项目名称</th><th>上课时间</th><th>上课节次</th><th>上课教师</th>
					<th>实验室</th><th>班级名称</th><th>指导教师</th>
				</tr> 
			</thead>
			<tbody>
			
			</tbody>
		</table>
		
		<div style="text-align: center;padding-top: 20px;">
			<a class="myBtn" style="padding: 10px 20px 10px 20px;font-size:15px;" onclick="nextStep()">下一步</a>
		</div>
		
		<script>
			var uploadOk = false;
			function uploadSuccess(obj){
				tip(obj.msg);
	 
				if(!obj.success){ 
					var files = uploader.getFiles();
					for(var i =0;i<files.length;i++){
						uploader.removeFile(files[i]);
					}			
				}else{
					uploadOk = true;
					//显示table
					var list = obj.obj; 
					$('#courseTable tbody').html('');

					for(var i=0;i<list.length;i++){
						var c = list[i];
						var tr ="<tr>";
						tr +="<td>"+c.lessonNo+"</td>";
						tr +="<td>"+c.lessonName+"</td>"; 
						tr +="<td>"+c.teachItemName+"</td>";
						tr +="<td>"+c.week+"</td>";
						tr +="<td>"+c.courseOrder+"</td>";
						tr +="<td>"+c.teacherName+"</td>";
						tr +="<td>"+c.labName+"</td>";
						tr +="<td>"+c.gradeInfo+"</td>";
						tr +="<td>"+getShowText(c.coacher)+"</td>";
						tr+="</tr>";
						
						$('#courseTable tbody').append(tr);
 					}
				}
			} 
			
			function getShowText(obj){
				return obj == null?"":obj;
			}
			
		 
			
			function nextStep(){
				if(!uploadOk){
					tip("请导入课程表文件！");
					return;
				}
				
				var id = $('#semesterId').val();
				window.location="teachCourseScheduleController.do?&showImport2&semesterId="+id;
			}
		 
			
			<c:if test="${error != null}">
				alert("${error}");
			</c:if>
			
		</script>
 </body>
 